<%@page import="org.apache.jasper.tagplugins.jstl.core.ForEach"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
img{
	width: 150px;
	height:150px;
	
	margin:30px;
}
</style>
</head>
<body>
<h2>商品列表</h2>
<img src="/day02/product/1.jpg"/><a href="/day02/product?pid=1">电冰箱</a>
<img src="/day02/product/2.jpg"/><a href="/day02/product?pid=2">电脑</a>
<img src="/day02/product/3.jpg"/><a href="/day02/product?pid=3">电视机</a>
<hr>
<img src="/day02/product/4.jpg"/><a href="/day02/product?pid=4">手机</a>
<img src="/day02/product/5.jpg"/><a href="/day02/product?pid=5">洗衣机</a>
<hr>
<h2>浏览记录</h2>
<%
Cookie [] ck = request.getCookies();

Cookie product = null;
if(ck != null){
	for(Cookie c:ck){
		if(c.getName().equals("product")){
			product = c;
		}
	}
}
if(product==null){
	%>
	<h3>暂无浏览记录</h3>
	<%
}else{
	String value = product.getValue();
	String [] ps = value.split("-");
	for(String s:ps){
		%>
		<img src="/day02/product/<%=s%>.jpg">
		<%
	}
}
%>
</body>
</html>